<?php

 /**
  * Objektklasse "Database" 
  * Hier steht alle objektbezogene Logik! 
  * @author Projektgruppe mCRM
  * @version 4.0.1
  */
  
 require_once("model/database.inc.php");
  
 // 
 class post
 {
	var $id;
	
 
 /**
  * Verbindung zur Datenbank
  */
  
    function __construct($post_id)
	{
		if($post_id==0)
			return;
				
		$this->id = $post_id; 		
		
	}
  
	function getdata()
	{
			$db = new database();
			$sqlstring="Select * from post WHERE postid  = '". $this->id ."'";
			$information = $db->sendsql($sqlstring);
			return $information;
	}
	
	function gethistory()
	{
			$db = new database();
			$sqlstring="Select no, contactid, Name, Notiz, Datum from notizen WHERE contactid like '%". $id ."%' ORDER BY Datum DESC";			
			$information = $db->sendsql2($sqlstring);
			return $information;
	}
	

	 
	function updatepost($title,$description)
					{ 
					 $sql= "UPDATE post 
								SET ";
							 if($title!="") 				$sql  .= "title		='". $title	."',";
							 if($description!="") 			$sql  .= "description		='". $description	."',";
						
							 $sql=substr($sql, 0, -1);						
							 $sql .=" WHERE postid='". $this->id ."';";
					
					$db = new database();
					$db->savesql($sql);
					
					}
					
	function createpost($title,$description)
					{ 
					 $sql= "insert into post (title, description) 
								values('". $title ."','". $description ."');";							
					
					$db = new database ();
					$this->id = $db->savesql($sql);
					return $this->id;
					}
	 
}
?>